package com.feeyin.radar.crm.dao.impl;

import com.feeyin.radar.commons.Page;
import com.feeyin.radar.crm.dao.LinkmanUpdateHistoryDAO;
import com.feeyin.radar.crm.model.Linkman;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class LinkmanUpdateHistoryDAOImpl extends SqlMapClientDaoSupport
  implements LinkmanUpdateHistoryDAO
{
  public List getPageLinkmanUpdateHistorysByCustomerIdAndLinkmanId(Integer customerId, Integer linkmanId, Page page)
  {
    Map map = new HashMap();
    map.put("customerId", customerId);
    map.put("linkmanId", linkmanId);
    map.put("pageStartRow", Integer.valueOf(page.getPageStartRow()));
    map.put("pageEndRow", Integer.valueOf(page.getPageEndRow()));
    return getSqlMapClientTemplate().queryForList("getPageLinkmanUpdateHistorysByCustomerIdAndLinkmanId", map);
  }

  public Integer getPageLinkmanUpdateHistorysCountByCustomerIdAndLinkmanId(Integer customerId, Integer linkmanId)
  {
    Map map = new HashMap();
    map.put("customerId", customerId);
    map.put("linkmanId", linkmanId);
    return (Integer)getSqlMapClientTemplate().queryForObject("getPageLinkmanUpdateHistorysCountByCustomerIdAndLinkmanId", map);
  }

  public Linkman getLinkmanUpdateHistory(Integer id) {
    return (Linkman)getSqlMapClientTemplate().queryForObject("getLinkmanUpdateHistory", id);
  }

  public boolean insertLinkmanUpdateHistory(Linkman linkman) {
    if ((linkman == null) || (linkman.getLinkmanId() == null)) return false;
    Integer result = (Integer)getSqlMapClientTemplate().insert("insertLinkmanUpdateHistory", linkman);
    return result != null;
  }
}